﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Common/Master/PopupDiv.master" AutoEventWireup="true" CodeBehind="Edit.aspx.cs" Inherits="Forum.Web.Admin.UForum.Group.Edit" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
        .style1
        {
            width: 80px; height:30px; text-align:right;
        }
       .style2
       {
           text-align:left; padding-left:5px;
       }
       .style3
       {
           width:100px; text-align:right;
       }
    </style>
    <script type="text/javascript">
        var manageTypeID =  <%=(int)Forum.Entity.Group.GroupType.管理组 %>;//管理组的
        function validate()
        {
            var groupName = $("#<%=Name.ClientID %>").val();
            var typeID = parseInt($("#<%=TypeID.ClientID %>").val());
            var creditMin = $("#<%=CreditMin.ClientID %>").val();
            var creditMax = $("#<%=CreditMax.ClientID %>").val();
            var starCount = $("#<%=StarCount.ClientID %>").val();
            var maxAttachSize = $("#<%=MaxAttachSize.ClientID %>").val();
            if ($.trim(groupName) == "")
            {
                alert("请输入用户组名");
                $("#<%=Name.ClientID %>").get(0).focus();
                return false;
            }
            var reg = /^\d+$/;
            
            if(!reg.test($.trim(starCount)))
            {
                if($.trim(starCount)== "")
                {
                    alert("请输入星星数");
                }
                else
                {
                    alert("星星数格式不正确");
                }
                $("#<%=StarCount.ClientID %>").get(0).focus();
                return false;
            }
            
            if(!reg.test($.trim(maxAttachSize)))
            {
                if($.trim(maxAttachSize)== "")
                {
                    alert("请输入允许上传的附件大小");
                }
                else
                {
                    alert("附件大小格式不正确");
                }
                $("#<%=MaxAttachSize.ClientID %>").get(0).focus();
                return false;
            }
            
            if(typeID != manageTypeID)
            {                               
 
                if(!reg.test($.trim(creditMin)))
                {
                    alert("请输入正确格式积分下限");
                    $("#<%=CreditMin.ClientID %>").get(0).focus();
                    return false;
                }
                if(!reg.test($.trim(creditMax)))
                {
                    alert("请输入正确格式积分上限");
                    $("#<%=CreditMax.ClientID %>").get(0).focus();
                    return false;
                }
                
                if(parseInt(creditMin)>= parseInt(creditMax))
                {
                    alert("积分上限必须大于积分下限");
                    $("#<%=CreditMax.ClientID %>").get(0).focus();
                    return false;
                }
            }

            return true;
        }

        $(function()
        {
            $("form").bind("submit", function()
            {               
                return validate();
            });
            $("#<%=TypeID.ClientID %>").bind("change",function()
            {                
                if($(this).val() == manageTypeID)
                {
                    with($("#<%=CreditMin.ClientID %>"))
                    {
                        attr("disabled","disabled");
                        css("background-color","#D6D3CE");                        
                    }
                    $("#spanMin").css("display","none");
                    
                    with($("#<%=CreditMax.ClientID %>"))
                    {
                        attr("disabled","disabled");                    
                        css("background-color","#D6D3CE");
                    }
                    $("#spanMax").css("display","none");
                   
                }
                else
                {
                    $("#<%=CreditMin.ClientID %>").removeAttr("disabled");
                    $("#<%=CreditMin.ClientID %>").css("background-color","");
                    $("#spanMin").css("display","");
                    
                    $("#<%=CreditMax.ClientID %>").removeAttr("disabled");
                    $("#<%=CreditMax.ClientID %>").css("background-color","");
                    $("#spanMax").css("display","");
                }
            });
        }
        );
       
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<asp:Panel ID="pnlMain" runat="server" CssClass="pnlMain">
        <table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height:99px;">
            <tr>
                <td class="style1">
                    <span style="color:Red;">*</span>&nbsp;用户组名：
                </td>
                <td class="style2">
                    <asp:TextBox ID="Name" runat="server" Width="100px" CssClass="txt"></asp:TextBox>                    
                </td>
                <td class="style3">
                    组类型：
                </td>
                <td class="style2">
                    <asp:DropDownList ID="TypeID" runat="server">
                    </asp:DropDownList>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <span style="color:Red;" id="spanMin">*</span>&nbsp;积分下限：
                </td>
                <td class="style2">
                    <asp:TextBox ID="CreditMin" runat="server" Width="100px" CssClass="txt"></asp:TextBox>
                </td>
                <td class="style3">
                    <span style="color:Red;"  id="spanMax">*</span>&nbsp;积分上限：
                </td>
                <td class="style2">
                    <asp:TextBox ID="CreditMax" runat="server" Width="100px" CssClass="txt"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td class="style1">
                    <span style="color:Red">*</span>&nbsp;星星数：
                </td>
                <td class="style2">
                    <asp:TextBox ID="StarCount" runat="server" Width="100px" CssClass="txt"></asp:TextBox>
                    
                </td>
                <td class="style3">
                    <span style="color:Red;">*</span>&nbsp;<span style="margin-right:1em;">上传附件允许</span><br />
                    的最大字节数：
                </td>
                <td class="style2">
                    <asp:TextBox ID="MaxAttachSize" runat="server" Width="100px" CssClass="txt"></asp:TextBox>

                </td>
            </tr>
            
            
        </table>
    </asp:Panel>
    <asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowSummary="False"
        ShowMessageBox="True"></asp:ValidationSummary>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="ContentPlaceHolder2" runat="server">
<asp:Button ID="btnSave" runat="server" OnClick="btnSave_Click" Text="保存" />
</asp:Content>
